var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opens = _____WB$wombat$assign$function_____("opens"); /* ****************************************************************************** File: gciUSATv*.js Version: see gcion_version, below Copyright: Copyright (c) 2006, Gannett Inc. All rights reserved. ****************************************************************************** */ /* ==================================================================== */ /* Global settings */ /* ==================================================================== */ var gcion_rdb_cookie = "RDB"; var gcion_service = "gcion.ashx"; var gcion_site_code = "reg.usatoday.com"; var gcion_url = "https://web.archive.org/web/20131212132619/http://usatoday.app.ur.gcion.com/"; var gcion_usat_cookie = "zagCookie"; var gcion_version = "1.0.2r-USAT2007516"; /* ==================================================================== */ /* Defines the GCION global namespace */ /* ==================================================================== */ var GCION = window.GCION || {}; /* ==================================================================== */ /* Defines namespace function */ /* ==================================================================== */ /// /// Gets the specified namespace or creates it if it does not exist. /// /// The representation of the desired namespace. /// /// GCION.namespace("property.package"); /// GCION.namespace("GCION.property.package"); /// /// Either of the above would create GCION.property, then /// GCION.property.package. /// /// A reference to the namespace object. GCION.namespace = function(nameSpace) { if (!nameSpace || !nameSpace.length) return null; var levels = nameSpace.split("."); var currentNamespace = GCION; // GCION is implied, so it is ignored if it is included for (var i = (levels[0] == "GCION") ? 1 : 0; i < levels.length; ++i) { currentNamespace[levels[i]] = currentNamespace[levels[i]] || {}; currentNamespace = currentNamespace[levels[i]]; } return currentNamespace; }; /* ==================================================================== */ /* Register namespaces */ /* ==================================================================== */ GCION.namespace("Data"); GCION.namespace("Cookies"); GCION.namespace("Utils"); GCION.namespace("Sites"); GCION.namespace("Callback"); /* ==================================================================== */ /* Defines the GCION data object */ /* ==================================================================== */ /// /// Provides a class that defines the data structure of a GCION cookie. /// GCION.Data.GCION = function() {}; GCION.Data.GCION.prototype = { // GCION data GcionId: null, CookieVersion: null, CreationDate: null, RegistrationStatus: null, Sessions: null, // ZAITO data ZipCode: null, Gender: null, Occupation: null, Industry: null, CompanySize: null, YearOfBirth: null, Country: null, OriginatingSite: null, Email: null }; /* ==================================================================== */ /* Defines the Callback object */ /* ==================================================================== */ GCION.Callback.Add = function (handler) { GCION.Callback.Handlers.push(handler); }; GCION.Callback.Invoke = function () { var fns = GCION.Callback.Handlers; for (var n in fns) { fns[n].apply(GCION, arguments); } }; if (!GCION.Callback.Handlers) GCION.Callback.Handlers= []; /* ==================================================================== */ /* Defines the RDB data class */ /* ==================================================================== */ /// /// Provides a class that defines the data structure of a RDB cookie. /// GCION.Data.RDB = function() {}; GCION.Data.RDB.prototype = { Publisher: null, Version: null, ZipCode: null, ZipCodeExt: null, Country: null, State: null, Gender: null, Subscriber: null, IncomeLow: null, IncomeHigh: null, AgeLow: null, AgeHigh: null, Trait1: null, Trait2: null, Trait3: null, Trait4: null, Trait5: null, Trait6: null, Trait7: null, Trait8: null }; /* ==================================================================== */ /* Defines a generic cookie object */ /* ==================================================================== */ /// /// Provides an object for handling cookies. /// GCION.Cookies.Cookie = { /// /// Gets the value stored in the specified cookie. /// When domain is ambiguous, gets the longest value /// (which, presumably, contains the most information, /// and is thus the most pertinent). /// /// The name of the cookie. Get : function(name) { var values= (' '+document.cookie).match(new RegExp(' '+name+'=[^;]*', 'g')) || []; var valLen= 0; // length of best match, so far var result= null; for (var j= 0; j < values.length; j++) if (values[j].length > valLen) { valLen= values[j].length; result= unescape(values[j].substring(2+name.length)); } return result; }, /// /// Sets a value that is stored in the specified cookie. /// /// The name of the cookie. /// The value to store in the cookie. /// The expiration date of the cookie. /// The path to the cookie. /// The domain name for the cookie. /// A value indicating whether the cookie is secure. Set : function(name, value, expires, path, domain, secure) { var today = new Date(); today.setTime(today.getTime()); if (expires) expires = expires * 1000 * 60 * 60 * 24; var expirationDate = new Date(today.getTime() + (expires)); document.cookie = name + '=' + value + ((expires) ? ';expires=' + expirationDate.toGMTString() : '') + ((path) ? ';path=' + path : '\/' ) + ((domain) ? ';domain=' + domain : GCION.Utils.Data.GetDomainName()) + ((secure) ? ';secure' : ''); }, /// /// Removes the specified cookie. /// /// The name of the cookie. /// The path to the cookie. /// The domain name for the cookie. Remove : function(name, path, domain) { if (this.Get(name)) { document.cookie = name + '=' + ((path) ? ';path=' + path : '\/') + ((domain) ? ';domain=' + domain : GCION.Utils.Data.GetDomainName() ) + ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; } }, /// /// Gets a value indicating if the cookie exists. /// /// The name of the cookie. Exists : function(cookieName) { var cookieString = document.cookie; var cookieSet = cookieString.split(';'); var setSize = cookieSet.length; var cookiePieces = ""; var cookieData = ""; for (var x = 0; ((x < setSize) && (cookieData == "")); x++) { cookiePieces = cookieSet[x].split('='); if (cookiePieces[0].substring(0, 1) == ' ') cookiePieces[0] = cookiePieces[0].substring(1, cookiePieces[0].length); if (cookiePieces[0] == cookieName) return true; } return false; } }; /* ==================================================================== */ /* Defines the RDB object */ /* ==================================================================== */ /// /// Provides an object for handling RDB cookies. /// GCION.Cookies.RDB = { /// /// Gets a RDB data object filled with data from the specified cookie. /// /// The name of the cookie. GetData : function(cookieName) { // get the cookie var cookieData = GCION.Cookies.Cookie.Get(cookieName); // initialize RDB data object var cookie = new GCION.Data.RDB(); // set properties values cookie.Publisher = this.ToInt(cookieData.substring(0, 2)); cookie.Version = this.ToInt(cookieData.substring(2, 4)); cookie.ZipCode = this.ToInt(cookieData.substring(4, 10)); cookie.ZipCodeExt = this.ToInt(cookieData.substring(10, 14)); cookie.Country = this.GetString(cookieData.substring(14, 18)); cookie.Gender = this.ToInt(cookieData.substring(18, 20)); cookie.Subscriber = this.ToInt(cookieData.substring(20, 22)); cookie.IncomeLow = this.ToInt(cookieData.substring(22, 24)); cookie.IncomeHigh = this.ToInt(cookieData.substring(24, 26)); cookie.AgeLow = this.ToInt(cookieData.substring(26, 28)); cookie.AgeHigh = this.ToInt(cookieData.substring(28, 30)); cookie.Trait1 = this.ToInt(cookieData.substring(30, 32)); cookie.Trait2 = this.ToInt(cookieData.substring(32, 34)); cookie.Trait3 = this.ToInt(cookieData.substring(34, 36)); cookie.Trait4 = this.ToInt(cookieData.substring(36, 38)); cookie.Trait5 = this.ToInt(cookieData.substring(38, 40)); cookie.Trait6 = this.ToInt(cookieData.substring(40, 42)); cookie.Trait7 = this.ToInt(cookieData.substring(42, 44)); cookie.Trait8 = this.ToInt(cookieData.substring(44, 46)); return cookie; }, /// /// Converts a hexadecimal value to a integer value. /// /// The hexadecimal value to convert. ToInt : function(hex) { return parseInt(hex, 16); }, /// /// Converts the specified integer to a character. /// /// The integer value to convert. ToChar : function(integer) { return String.fromCharCode(integer); }, /// /// Gets a string for the specified hexadecimal value. /// /// The hexadecimal value to get as a string. GetString : function(hex) { var str = ""; for (var i = 0; i < hex.length; i+=2) { if (i != hex.length) { var value = hex.charAt(i) + hex.charAt(i + 1); str += this.ToChar(this.ToInt(value)); } } return str; } }; /* ==================================================================== */ /* Defines the Data object */ /* ==================================================================== */ /// /// Provides an object containing data handling utilities. /// GCION.Utils.Data = { /// /// Gets a value indicating if the specified object is null or empty. /// /// The object to determine it is null or empty. IsNullOrEmpty : function(object) { if (object == null || (object == '' && 'number' != typeof object) || object.length == 0 || object == "null" || object == "undefined") return true; else return false; }, /// /// Gets the top level domain name for the current site. /// GetDomainName : function() { var domain = window.location.host; var match = /([\w-]+)+\.[a-zA-Z]{2,3}$/i.exec(domain); return match ?"." + match[0] :domain; }, /// /// Gets the version number of the USAT GCION library. /// GetVersion : function() { return gcion_version; }, /// /// Gets the year of birth for the specified age. /// /// The age of the user. GetYob : function(age) { var today = new Date(); return today.getFullYear() - age; }, /// /// Gets the GCION URL and appends the specified query string parameters. /// /// A list of query string parameters to append. GetGcionUrl : function(paramsString) { // define the GCION URL if (gcion_url.charAt(gcion_url.length - 1) != "/") var url = gcion_url + "/" + gcion_service; else var url = gcion_url + gcion_service; // append query character to URL if a query string was passed if (!this.IsNullOrEmpty(paramsString)) url += "?" + paramsString + "&Path=" + escape(this.GetDomainName())+"&CacheDefeat="+new Date().getTime(); return url; } }; /* ==================================================================== */ /* Defines the Include object */ /* ==================================================================== */ // set global variable used by Include object var gcion_included_files = new Array(); /// /// Provides an object containing script include utilities. /// GCION.Utils.Include = { /// /// Appends a JavaScript include to the DOM. /// /// The name of the JavaScript file to include. /// The unique identifier for the JavaScript file to include. ToDom : function(scriptFilename, identifier) { // define DOM elements var htmlDoc = document.getElementsByTagName('head').item(0); var scriptTag = document.createElement('script'); // set tag attributes scriptTag.setAttribute('language', 'javascript'); scriptTag.setAttribute('type', 'text/javascript'); scriptTag.setAttribute('src', scriptFilename); // set identifier if specified if (!GCION.Utils.Data.IsNullOrEmpty(identifier)) scriptTag.setAttribute('id', identifier); // append tag to DOM htmlDoc.appendChild(scriptTag); return false; }, /// /// Dynamically includes a JavaScript file only once per page. /// /// The name of the JavaScript file to include. /// The unique identifier for the JavaScript file to include. Once : function(scriptFilename, identifier) { if (!this.InArray(scriptFilename, gcion_included_files)) { gcion_included_files[gcion_included_files.length] = scriptFilename; this.ToDom(scriptFilename, identifier); } }, /// /// Appends a JavaScript include inline to the DOM. /// /// The name of the JavaScript file to include. /// The unique identifier for the JavaScript file to include. Inline : function(scriptFilename, identifier) { // get the user agent var agent = navigator.userAgent.toLowerCase(); if (agent.indexOf("msie") != -1) document.write(''); else this.ToDom(scriptFilename, identifier); }, /// /// Determines if the JavaScript file was already included on the page. /// /// The name of the JavaScript include file. /// An array containing a collection of included JavaScript files. InArray : function(needle, haystack) { for (var i = 0; i < haystack.length; i++) { if (haystack[i] == needle) return true; } return false; } }; /* ==================================================================== */ /* Defines the Request object */ /* ==================================================================== */ /// /// Provides an object for obtaining query string parameters from an HTTP /// request. /// GCION.Utils.Request = function(querystring) { this.params = new Object(); this.QueryString = GCION.Utils.GetRequest; if (querystring == null) querystring = location.search.substring(1, location.search.length); if (querystring.length == 0) return; querystring = querystring.replace(/\+/g, ' '); var args = querystring.split('&'); // split out each name/value pair for (var i = 0; i < args.length; i++) { var value; var pair = args[i].split('='); var name = unescape(pair[0]); if (pair.length == 2) value = unescape(pair[1]); else value = name; this.params[name] = value; } }; GCION.Utils.GetRequest = function(key, defaultValue) { if (defaultValue == null) defaultValue = null; var value = this.params[key]; if (value == null) value = defaultValue; return value; }; /* ==================================================================== */ /* Defines the USAT site object */ /* ==================================================================== */ /// /// Provides an object for handling events for USAT. /// GCION.Sites.USAT = { /// /// Captures ZAGITO/O data from the specified GCION data object. /// /// A defined GCION data object. CaptureZagito : function(gcion) { // set the required query string parameters var querystring = "q=2&NoCookie=1&GCIONID=" + gcion.GcionId + "&YOB=" + gcion.YearOfBirth + "&Gender=" + gcion.Gender + "&Country=" + gcion.Country.toLowerCase() + "&OriginatingSite=" + escape(gcion_site_code); // set optional values if (!GCION.Utils.Data.IsNullOrEmpty(gcion.ZipCode)) { if (gcion.Country.toLowerCase() == "us") querystring += "&Zip=" + gcion.ZipCode; } if (!GCION.Utils.Data.IsNullOrEmpty(gcion.Occupation)) querystring += "&Occupation=" + gcion.Occupation; if (!GCION.Utils.Data.IsNullOrEmpty(gcion.Industry)) querystring += "&Industry=" + gcion.Industry; if (!GCION.Utils.Data.IsNullOrEmpty(gcion.CompanySize)) querystring += "&CompanySize=" + gcion.CompanySize; // ZAGITO/O the user GCION.Utils.Include.Once(GCION.Utils.Data.GetGcionUrl(querystring)); }, /// /// Converts a USAT cookie to a GCION cookie. /// ConvertToGCION : function() { // get existing ZAGITO/O data from RDB cookie if (GCION.Cookies.Cookie.Exists(gcion_rdb_cookie)) { // GCION.Utils.Include.Once(GCION.Utils.Data.GetGcionUrl("q=3&NoCookie=1")); // setTimeout("GCION.Sites.USAT.GetZagito()", 500); this.GetZagito(new GCION.Data.GCION()); } else if (GCION.Cookies.Cookie.Exists(gcion_usat_cookie)) { // get the USAT cookie var usatCookie = GCION.Cookies.Cookie.Get(gcion_usat_cookie); // only get data from version 3 of USAT ZAGITO cookie if (usatCookie.charAt(0) == 3) { // GCION.Utils.Include.Once(GCION.Utils.Data.GetGcionUrl("q=3&NoCookie=1")); // setTimeout("GCION.Sites.USAT.GetZagito()", 500); this.GetZagito(new GCION.Data.GCION()); } } }, /// /// Gets a GCION cookie object filled with USAT ZAGITO data. /// GetZagito : function(cookie) { if (GCION.Cookies.Cookie.Exists(gcion_rdb_cookie) && GCION.Cookies.Cookie.Exists(gcion_usat_cookie)) { // get the RDB cookie var rdbCookie = GCION.Cookies.RDB.GetData(gcion_rdb_cookie); // set properties cookie.Gender= 3-rdbCookie.Gender; cookie.Country = rdbCookie.Country.toString().toLowerCase(); cookie.ZipCode = rdbCookie.ZipCode; cookie.YearOfBirth = GCION.Utils.Data.GetYob((rdbCookie.AgeLow + rdbCookie.AgeHigh) / 2); // override with usat cookie // (required -- usat cookie has GCIONID) // then capture ZAGITO/O data this.GetZagito(cookie); } }, /* short property names -> long property names */ PropName : { cou: 'Country', fem: 'Gender', gci: 'GcionId', gdt: '', ind: 'Industry', job: 'Occupation', sav: '', sit: '', siz: 'CompanySize', yob: 'YearOfBirth', zip: 'ZipCode' }, /* names whose values need to be encoded as names */ NameName : { cou: 1, gci: 1, key: 1, sit: 1 }, /// /// Gets a GCION cookie object filled with USAT ZAITO data. /// GetZagito : function(cookie) { if (GCION.Cookies.Cookie.Exists(gcion_usat_cookie)) { // get the USAT cookie var usatCookie = this.ParseZagito(GCION.Cookies.Cookie.Get(gcion_usat_cookie)); // set properties for (var name in usatCookie) if (this.PropName[name]) switch (name) { case 'fem': cookie.Gender= 2-usatCookie[name]; break; default: cookie[this.PropName[name]]= usatCookie[name]; } // capture ZAGITO/O data if (!GCION.Utils.Data.IsNullOrEmpty(cookie)) GCION.Sites.USAT.CaptureZagito(cookie); } }, /// /// Parses a USAT cookie and returns its contents as a name/value pair array. /// /// The contents of the USAT ZAGITO/O cookie. ParseZagito : function(zagCookie) { zagCookie+="" var r = new Object(); r.version = parseInt(zagCookie); if (isNaN(r.version)) return {version: 2}; var nvps = zagCookie.split('n'); for (var j= 0; j < nvps.length; j++) { var nv = nvps[j].split('v'); if (2 == nv.length) { var nam = this.DecodeName(nv[0]); var val = this.NameName[nam] ? this.DecodeName(nv[1]) : this.DecodeNumber(nv[1]); r[nam] = val; } } return r; }, /// ///web.archive.org/web/20131212132619/http://returns cookie value /// EncodeZagito : function(obj) { var r = obj.version+' '; for (var nm in obj) { if (3 == nm.length && !GCION.Utils.Data.IsNullOrEmpty(obj[nm])) { var val= this.NameName[nm] ?this.EncodeName(obj[nm]) :this.EncodeNumber(obj[nm]); r+='n'+this.EncodeName(nm)+'v'+val } } return r; }, /// ///web.archive.org/web/20131212132619/http://sets zagCookie ///The zagito cookie object to be saved SetZagito : function(obj) { GCION.Cookies.Cookie.Set(gcion_usat_cookie, this.EncodeZagito(obj), 3650, '/', '.usatoday.com'); }, /// /// Converts an integer value to a hexadecimal value. /// /// The integer value to convert. EncodeNumber : function(integer) { if (integer < 10) return integer; var result = ""; for (var result = ""; integer; integer>>>=4) result = "0123456789abcdef".charAt(integer&0xf) + result; return result; }, /// /// Encode sequence of characters as sequence of hexadecimal pairs /// /// The ascii string to encode as hex. EncodeName : function(name) { var result = ""; for (var i = 0; i < name.length; i++) result += this.EncodeNumber(name.charCodeAt(i)); return result; }, /// /// Converts a hexadecimal value to a number. /// /// The hexadecimal value to convert. HexToNumber : function(str) { var r = new Array(str.length); var strs = str.split(''); for (var j= 0; j < strs.length; j++) r[j]= '0123456789ABCDEF'.indexOf(strs[j]); return r; }, /// /// Decodes a number from its hexadecimal format. /// /// The number to decode. DecodeNumber : function(number) { return parseInt(number, 16); }, /// /// Decodes a name from its hexadecimal format. /// /// The name to decode. DecodeName : function(name) { var r = ''; for (var j= 0; j